LAGOS Analysis

Loading in data

First download and then specifically grab the locus (or site lat longs)

# #Lagos download script
# #lagosne_get(version='1.087.1',dest_folder = LAGOSNE:::lagos_path())
# 
# #Load in lagos
# #lagos <- lagosne_load(version='1.087.1')
# 
# #Grab the lake centroid info
# #lake_centers <- lagos$locus

#Plan B:
load('lake_centers.Rdata')

Convert to spatial data

#Look at the column names
#names(lake_centers)

#Look at the structure
#str(lake_centers)

#View the full dataset
#View(lake_centers %>% slice(1:100))

spatial_lakes <- st_as_sf(lake_centers,coords=c('nhd_long','nhd_lat'),
                          crs=4326) %>%
  st_transform(2163)

#Subset for plotting
subset_spatial <- spatial_lakes %>%
  slice(1:100)

#Dynamic mapviewer
mapview(subset_spatial)

Subset to only Minnesota

states <- us_states()

#Plot all the states to check if they loaded
mapview(states)
minnesota <- states %>%
  filter(name == 'Minnesota') %>%
  st_transform(2163)

#Subset lakes based on spatial position
minnesota_lakes <- spatial_lakes[minnesota,]

#Plotting the first 1000 lakes
minnesota_lakes %>%
  slice(1:1000) %>%
  arrange(lake_area_ha) %>%
  mapview(.,zcol = 'lake_area_ha')

In-Class work

1) Show a map outline of Iowa and Illinois (similar to Minnesota map upstream)

#Your code here

IA_IL <- states %>%
  filter(name == 'Iowa'| name == 'Illinois' ) %>%
  st_transform(2163)

mapview(IA_IL)

2) Subset LAGOS data to these sites, how many sites are in Illinois and Iowa combined? How does this compare to Minnesota?

Minnesota has 29,038 lakes while Iowa and Illinois combined have 16,466 lakes.

#Subset lakes based on spatial position
IA_IL_lakes <- spatial_lakes[IA_IL,]

#Plotting the first 1000 lakes
IA_IL_lakes %>%
  slice(1:1000) %>%
  arrange(lake_area_ha) %>%
  mapview(.,zcol = 'lake_area_ha')

3) What is the distribution of lake size in Iowa vs. Minnesota?

  • Here I want to see a histogram plot with lake size on x-axis and frequency on y axis (check out geom_histogram)
IA_MN <- states %>%
  filter(name %in% c('Iowa', 'Minnesota')) %>%
  st_transform(2163)

IA_MN_lakes <- spatial_lakes %>%
  st_join(.,IA_MN) %>%
  filter(!is.na(name))

ggplot(IA_MN_lakes, aes(lake_area_ha))+
  geom_histogram()+
  facet_wrap(~name, ncol=1) +
  scale_x_log10()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

4) Make an interactive plot of lakes in Iowa and Illinois and color them by lake area in hectares

#Plotting the first 1000 lakes
IA_IL_lakes %>%
  slice(1:1000) %>%
  arrange(lake_area_ha) %>%
  mapview(.,zcol = 'lake_area_ha')

5) What other data sources might we use to understand how reservoirs and natural lakes vary in size in these three states?

We could use NHD High Resolution waterbody data, or satellite imagery along with state shapfiles (such as the package mapview).